package com.example.monitor.model.VO;

import com.example.monitor.model.DO.AlarmRecord;
import com.example.monitor.model.enums.AlarmStatus;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;

@Data
@AllArgsConstructor // 添加Lombok注解生成全参构造
@NoArgsConstructor
public class AlarmRecordVO {
    private Long alarmId;
    private String workerId;
    private String workerName;
    private String workshop;
    private String alarmType;
    private Timestamp alarmTime;
    private AlarmStatus status;
    private String thumbnailUrl;

    //静态工厂方法
    public static AlarmRecordVO fromEntity(AlarmRecord record) {
        AlarmRecordVO vo = new AlarmRecordVO();
        vo.setAlarmId(record.getAlarmId());
        if (record.getWorker() != null) {
            vo.setWorkerId(record.getWorker().getWorkerId());
            vo.setWorkerName(record.getWorker().getName());
        }
        vo.setWorkshop(record.getWorkshop());
        vo.setAlarmType(record.getAlarmType());
        vo.setAlarmTime(record.getAlarmTime());
        vo.setStatus(record.getStatus());
        vo.setThumbnailUrl(record.getImageUrl());
        return vo;
    }
}

